package com.yuda.conf;


import com.alibaba.alicloud.context.AliCloudProperties;
import com.alibaba.alicloud.context.oss.OssProperties;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OssConfig {

    @Value("${spring.cloud.alicloud.oss.endpoint-inter}")
    private String interEndpoint;

    @Bean
    public OSS ossClient(AliCloudProperties aliCloudProperties,
                         OssProperties ossProperties) {
        return new OSSClientBuilder().build(ossProperties.getEndpoint(),
                aliCloudProperties.getAccessKey(), aliCloudProperties.getSecretKey(),
                ossProperties.getConfig());
    }


}
